package com.lft.gulimall.product.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.lft.common.valid.AddGroup;
import com.lft.common.valid.ListValue;
import com.lft.common.valid.UpdateGroup;
import com.lft.common.valid.UpdateStatusGroup;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import javax.validation.constraints.Pattern;
import java.io.Serializable;

/**
 * 品牌
 * @author Laifengting
 * @email laifengting@foxmail.com
 * @date 2020-11-05 00:08:14
 */
@Data
@TableName ("pms_brand")
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;
	
	/**
	 * 品牌id
	 */
	@Null (message = "新增不能指定品牌ID", groups = {AddGroup.class})
	@NotNull (message = "修改必须指定品牌ID", groups = {UpdateGroup.class})
	@TableId
	private Long brandId;
	/**
	 * 品牌名
	 * // @NotBlank 不能为空，必须包含一个字符
	 * // @NotNull	不能为空，可以是空串""
	 * // @NotEmpty 不能为空，也不能是空串
	 */
	@NotBlank (message = "品牌名不能为空", groups = {AddGroup.class, UpdateStatusGroup.class})
	private String name;
	/**
	 * 品牌logo地址
	 */
	@URL (message = "logo地址必须是一个合法的url地址", groups = {AddGroup.class, UpdateGroup.class})
	@NotBlank (message = "logo地址不能为空", groups = {AddGroup.class})
	private String logo;
	/**
	 * 介绍
	 */
	private String descript;
	/**
	 * 显示状态[0-不显示；1-显示]
	 */
	// @TableLogic (value = "1", delval = "0")
	@NotNull (groups = {AddGroup.class, UpdateStatusGroup.class})
	@ListValue (values = {0, 1}, groups = {AddGroup.class, UpdateStatusGroup.class})
	private Integer showStatus;
	/**
	 * 检索首字母
	 */
	@NotBlank (message = "检索首字母不能为null或者空串", groups = {AddGroup.class})
	@Pattern (regexp = "^[A-Za-z]+$", message = "检索首字母必须是一个字母", groups = {AddGroup.class, UpdateGroup.class})
	private String firstLetter;
	/**
	 * 排序
	 */
	@NotNull (message = "排序不能为null或者空串", groups = {AddGroup.class})
	@Min (value = 0, message = "排序必须大于等于0", groups = {AddGroup.class, UpdateGroup.class})
	private Integer sort;
	
}
